package com.leyou.order.config;

import com.leyou.order.interceptors.UserInterceptor;
import com.leyou.order.interceptors.UserInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author: wzh
 * @Date: 2019/4/16 23:10
 * @Description: 拦截器生效
 */
@EnableConfigurationProperties(JwtProperties.class)
public class MvcConfig implements WebMvcConfigurer {

    @Autowired
    private JwtProperties prop;
    /**
     * 添加一个拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截一切路径
        registry.addInterceptor(new UserInterceptor(prop)).addPathPatterns("/**");
    }
}
